/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Serif SC', serif;
    line-height: 1.6;
    color: #e8e6e3;
    background:
        linear-gradient(rgba(20, 20, 30, 0.85), rgba(10, 10, 20, 0.95)),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 400 400"><defs><pattern id="parchment" x="0" y="0" width="400" height="400" patternUnits="userSpaceOnUse"><rect fill="%231a1625" width="400" height="400"/><path d="M0,0 L400,400 M400,0 L0,400" stroke="%23302b40" stroke-width="1" opacity="0.1"/><path d="M200,0 L200,400 M0,200 L400,200" stroke="%23302b40" stroke-width="1" opacity="0.1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23parchment)"/></svg>');
    background-attachment: fixed;
    min-height: 100vh;
    position: relative;
}

/* 添加历史感的装饰边框 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(90deg, transparent 97%, rgba(139, 69, 19, 0.4) 100%),
        linear-gradient(0deg, transparent 97%, rgba(139, 69, 19, 0.4) 100%),
        linear-gradient(90deg, rgba(139, 69, 19, 0.4) 0%, transparent 3%),
        linear-gradient(0deg, rgba(139, 69, 19, 0.4) 0%, transparent 3%);
    pointer-events: none;
    z-index: 1000;
}

/* 添加角落装饰 */
body::after {
    content: '';
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid rgba(193, 154, 107, 0.2);
    pointer-events: none;
    z-index: 999;
}

/* 添加历史纹章装饰 */
.header::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background:
        radial-gradient(circle, rgba(193, 154, 107, 0.1) 0%, transparent 70%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50,10 L60,40 L90,40 L65,60 L75,90 L50,70 L25,90 L35,60 L10,40 L40,40 Z" fill="none" stroke="%23c19a6b" stroke-width="2" opacity="0.3"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.1;
    pointer-events: none;
}

/* 添加微妙的纹理效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(120, 80, 40, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(80, 60, 120, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(160, 120, 80, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 998;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background:
        linear-gradient(135deg, rgba(44, 33, 27, 0.95) 0%, rgba(28, 21, 17, 0.98) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><pattern id="velvet" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><rect fill="%231c1511" width="100" height="100"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="%2330251f" stroke-width="0.5" opacity="0.2"/></pattern></defs><rect width="100%" height="100%" fill="url(%23velvet)"/></svg>');
    color: #f5e6d3;
    padding: 3rem 0;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border-bottom: 3px solid #8b4513;
    position: relative;
    overflow: hidden;
}

/* 头部装饰边框 */
.header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px solid rgba(139, 69, 19, 0.3);
    pointer-events: none;
}

.title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    color: #f5e6d3;
    letter-spacing: 1px;
    position: relative;
    display: inline-block;
}

.title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 10%;
    right: 10%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #c19a6b, transparent);
}

.subtitle {
    font-size: 1.4rem;
    opacity: 0.85;
    font-weight: 400;
    color: #d4b896;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}

/* 导航栏 */
.navigation {
    background:
        linear-gradient(135deg, rgba(52, 39, 31, 0.95) 0%, rgba(40, 30, 24, 0.98) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80"><defs><pattern id="navPattern" x="0" y="0" width="80" height="80" patternUnits="userSpaceOnUse"><rect fill="%23281e18" width="80" height="80"/><path d="M0,0 L80,80 M80,0 L0,80" stroke="%233c2d23" stroke-width="0.5" opacity="0.2"/></pattern></defs><rect width="100%" height="100%" fill="url(%23navPattern)"/></svg>');
    padding: 1.2rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #8b4513;
}

.nav-list {
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: #d4b896;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 600;
    border: 1px solid transparent;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(193, 154, 107, 0.2), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(139, 69, 19, 0.3);
    border-color: #c19a6b;
    color: #f5e6d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.4);
}

/* 主要内容区域 */
.main-content {
    padding: 3rem 0;
    position: relative;
}

.section {
    margin-bottom: 3rem;
    background:
        linear-gradient(135deg, rgba(40, 32, 28, 0.9) 0%, rgba(30, 24, 20, 0.95) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><defs><pattern id="sectionPattern" x="0" y="0" width="120" height="120" patternUnits="userSpaceOnUse"><rect fill="%231e1814" width="120" height="120"/><path d="M0,0 L120,120 M120,0 L0,120" stroke="%23302822" stroke-width="1" opacity="0.15"/></pattern></defs><rect width="100%" height="100%" fill="url(%23sectionPattern)"/></svg>');
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.4s ease;
    border: 1px solid rgba(139, 69, 19, 0.3);
    position: relative;
    overflow: hidden;
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b4513, #c19a6b, #8b4513);
}

.section:hover {
    transform: translateY(-5px);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-color: rgba(193, 154, 107, 0.5);
}

.section h2 {
    color: #f5e6d3;
    font-size: 2.8rem;
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 3px solid #c19a6b;
    padding-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
    position: relative;
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 25%;
    right: 25%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(193, 154, 107, 0.5), transparent);
}

/* 概览网格 */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.overview-card {
    background:
        linear-gradient(135deg, rgba(60, 45, 35, 0.9) 0%, rgba(40, 30, 25, 0.95) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><pattern id="cardPattern" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><rect fill="%23281e18" width="100" height="100"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="%233c2d23" stroke-width="0.8" opacity="0.2"/></pattern></defs><rect width="100%" height="100%" fill="url(%23cardPattern)"/></svg>');
    color: #f5e6d3;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    transition: all 0.4s ease;
    border: 1px solid rgba(139, 69, 19, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.overview-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8b4513, #c19a6b, #8b4513);
}

.overview-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    border-color: rgba(193, 154, 107, 0.6);
}

.overview-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.overview-card p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

/* 家谱图样式 */
.tree-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.search-container {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
}

.search-input {
    padding: 1rem 1.5rem;
    border: 2px solid #c19a6b;
    border-radius: 30px;
    font-family: inherit;
    font-size: 1rem;
    width: 350px;
    outline: none;
    transition: all 0.3s ease;
    background: rgba(40, 32, 28, 0.8);
    color: #f5e6d3;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.search-input::placeholder {
    color: #d4b896;
    opacity: 0.7;
}

.search-input:focus {
    border-color: #8b4513;
    background: rgba(50, 40, 35, 0.9);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
}

.search-btn {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    color: #f5e6d3;
    border: 2px solid #c19a6b;
    padding: 1rem 2rem;
    border-radius: 30px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.search-btn:hover {
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.5);
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(135deg, rgba(60, 45, 35, 0.9) 0%, rgba(40, 30, 25, 0.95) 100%);
    color: #f5e6d3;
    border: 2px solid #c19a6b;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: linear-gradient(135deg, rgba(80, 60, 45, 0.9) 0%, rgba(60, 45, 35, 0.95) 100%);
    border-color: #8b4513;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
}

.tree-container {
    background:
        linear-gradient(135deg, rgba(35, 28, 24, 0.95) 0%, rgba(25, 20, 16, 0.98) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" viewBox="0 0 150 150"><defs><pattern id="treePattern" x="0" y="0" width="150" height="150" patternUnits="userSpaceOnUse"><rect fill="%23191410" width="150" height="150"/><path d="M0,0 L150,150 M150,0 L0,150" stroke="%232a221c" stroke-width="1" opacity="0.1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23treePattern)"/></svg>');
    border: 2px solid rgba(139, 69, 19, 0.6);
    border-radius: 15px;
    padding: 2rem;
    min-height: 600px;
    overflow: auto;
    position: relative;
    box-shadow:
        inset 0 2px 10px rgba(0, 0, 0, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.6);
}

.tree-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b4513, #c19a6b, #8b4513);
    border-radius: 15px 15px 0 0;
}

#family-tree-canvas {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border-radius: 8px;
}

/* 时间线样式 */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 2rem auto;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #e74c3c;
    transform: translateX(-50%);
}

.timeline-item {
    display: flex;
    align-items: center;
    margin: 2rem 0;
    position: relative;
}

.timeline-item:nth-child(odd) {
    flex-direction: row-reverse;
}

.timeline-year {
    background: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 50%;
    min-width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.timeline-content {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin: 0 2rem;
    flex: 1;
    border-left: 4px solid #3498db;
}

.timeline-item:nth-child(odd) .timeline-content {
    border-left: none;
    border-right: 4px solid #3498db;
}

.timeline-content h4 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

/* 历史内容样式 */
.history-content {
    line-height: 1.8;
}

.history-content h3 {
    color: #2c3e50;
    margin: 1.5rem 0 1rem 0;
    font-size: 1.5rem;
}

.history-content ul {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

.history-content li {
    margin-bottom: 0.5rem;
}

.monarchs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.monarch-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease;
}

.monarch-card:hover {
    transform: translateY(-5px);
}

.monarch-card h4 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

/* 分支王朝样式 */
.branches-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.branch-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.branch-card:hover {
    transform: translateY(-5px);
}

.branch-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 0.5rem;
}

.branch-card p {
    margin: 0.8rem 0;
    line-height: 1.6;
}

/* 页脚样式 */
.footer {
    background:
        linear-gradient(135deg, rgba(44, 33, 27, 0.95) 0%, rgba(28, 21, 17, 0.98) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><pattern id="footerPattern" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"><rect fill="%231c1511" width="100" height="100"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="%2330251f" stroke-width="0.5" opacity="0.2"/></pattern></defs><rect width="100%" height="100%" fill="url(%23footerPattern)"/></svg>');
    color: #f5e6d3;
    text-align: center;
    padding: 3rem 0;
    margin-top: 4rem;
    border-top: 3px solid #8b4513;
    position: relative;
    overflow: hidden;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c19a6b, transparent);
}

.footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .nav-list {
        flex-direction: column;
        gap: 0.5rem;
    }

    .timeline::before {
        left: 30px;
    }

    .timeline-item {
        flex-direction: row !important;
    }

    .timeline-year {
        margin-right: 1rem;
    }

    .overview-grid,
    .monarchs-grid,
    .territories-grid {
        grid-template-columns: 1fr;
    }

    .tree-controls {
        flex-direction: column;
        align-items: center;
    }

    .control-btn {
        width: 200px;
    }
}

/* 滚动动画 */
.section {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 生物课本风格家谱图样式 */
.member-group {
    cursor: pointer;
    transition: all 0.2s ease;
}

.member-group:hover rect {
    filter: brightness(1.1);
    stroke-width: 2px;
    stroke: #e74c3c;
}

.member-name {
    font-family: 'Noto Serif SC', serif;
    font-weight: 600;
    user-select: none;
    pointer-events: none;
}

.member-reign {
    font-family: 'Noto Serif SC', serif;
    user-select: none;
    pointer-events: none;
}

/* 代际线样式 */
.generation-line {
    stroke: #ddd;
    stroke-width: 1;
    stroke-dasharray: 5,5;
}

/* 血缘连线样式 */
.bloodline {
    stroke: #666;
    stroke-width: 2;
    fill: none;
}

/* 代际标记样式 */
.generation-label {
    font-family: 'Noto Serif SC', serif;
    font-size: 12px;
    font-weight: bold;
    fill: #666;
    user-select: none;
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 模态框动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}